<?php
/**
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_2
 * @license    GNU/GPL
*/
 
// No direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.view');
 
/**
 * HTML View class for the JobsWorld Component
 *
 * @package    JobsWorld
 */
 
class JobsViewMyjobs extends JView
{
    function display($tpl = null)
    {
		global $mainframe, $option;
        $model = &$this->getModel();
		$session =& JFactory::getSession();
		
		$items_job = JModel::getInstance( 'myjobs', 'JobsModel');
		$this->assignRef('items_job',		$items_job);
		
		
		if(isset($_POST['frm_1']))
		{
			$session->set( 'landsdel', $_POST['region']);
		    $session->set( 'pris', $_POST['catid']);
		}
		if(isset($_POST['frm_2']))
		{
			$session->set( 'landsdel_2', $_POST['region_2']);
		    $session->set( 'pris_2', $_POST['catid_2']);
		}
		/*
		$items		= $this->get('data');
		$total		= $this->get('total');
		$pagination	= &$this->get('pagination');
		*/
		//$mainframe->setUserState($option.'filter_state','P');
		//$mainframe->setUserState($option.'filter_order_Dir','DESC');
		//$lists = array();
		//$lists['city'] 			= JHTML::_('list.category',  'city', 'com_city');
		//$lists['catid'] 			= JHTML::_('list.category',  'catid', 'com_jobs');
		//$this->assignRef('lists',		$lists);
		$city_html = '';
		$city = $model->getArrayCityDanish();
		
		$city_html = '<select id="region" name="region">';
		for($i=0;$i<sizeof($city);$i++) 
		{
			if(substr($session->get( 'landsdel'),0,4)==$city[$i]['from'])
			 $city_html .= '<option selected="selected" value="'.$city[$i]['from'].'-'.$city[$i]['to'].'">'.$city[$i]['name'].'</option>';
		    else
		     $city_html .= '<option value="'.$city[$i]['from'].'-'.$city[$i]['to'].'">'.$city[$i]['name'].'</option>';
		    	 
		}
		$city_html .= '</select>';
		
		$this->assignRef('city_html',		$city_html);
		
		
		
		
		$defalt_pris =  array(0=>(object)array("id"=>0,"title"=>"Alle"));
		$lpris = $model->getListPris();
		$lpris =array_merge($defalt_pris,$lpris);

		$pris_html = '<select id="catid" name="catid">';
		for($i=0;$i<sizeof($lpris);$i++) 
		{
			if($session->get( 'pris')==$lpris[$i]->id)
			 $pris_html .= '<option selected="selected" value="'.$lpris[$i]->id.'">'.$lpris[$i]->title.'</option>';
		    else
		     $pris_html .= '<option value="'.$lpris[$i]->id.'">'.$lpris[$i]->title.'</option>';
		    	 
		}
		$pris_html .= '</select>';
		
		$this->assignRef('pris_html',		$pris_html);
		
		
		
		
        $lists = array();		
		$lists['pris'] 			= JHTML::_('list.category',  'catid', 'com_jobs',null,null,null,1,0);
		$this->assignRef('lists',		$lists);
		$jsort = $model->getSortJobs();
		$this->assignRef('jsort',		$jsort);
		
		
		
		$city_html_2 = '';
		$city = $model->getArrayCityDanish();
		
		$city_html_2 = '<select id="region_2" name="region_2">';
		for($i=0;$i<sizeof($city);$i++) 
		{
			if(substr($session->get( 'landsdel_2'),0,4)==$city[$i]['from'])
			 $city_html_2 .= '<option selected="selected" value="'.$city[$i]['from'].'-'.$city[$i]['to'].'">'.$city[$i]['name'].'</option>';
		    else
		     $city_html_2 .= '<option value="'.$city[$i]['from'].'-'.$city[$i]['to'].'">'.$city[$i]['name'].'</option>';
		    	 
		}
		$city_html_2 .= '</select>';
		
		$this->assignRef('city_html_2',		$city_html_2);
		
		
		
		$defalt_pris =  array(0=>(object)array("id"=>0,"title"=>"Alle"));
		$lpris = $model->getListPris();
		$lpris =array_merge($defalt_pris,$lpris);
		
		//$defalt_pris = (object) array("id"=>0,"title"=>"Alle");
		//arr
		//$lpris = array_merge($lpris,$defalt_pris);
		
		$pris_html_2 = '<select id="catid_2" name="catid_2">';
		for($i=0;$i<sizeof($lpris);$i++) 
		{
			if($session->get( 'pris_2')==$lpris[$i]->id)
			 $pris_html_2 .= '<option selected="selected" value="'.$lpris[$i]->id.'">'.$lpris[$i]->title.'</option>';
		    else
		     $pris_html_2 .= '<option value="'.$lpris[$i]->id.'">'.$lpris[$i]->title.'</option>';
		    	 
		}
		$pris_html_2 .= '</select>';
		
		$this->assignRef('pris_html_2',		$pris_html_2);
		
		$jsort_2 = $model->getSortMyJobs();
		$this->assignRef('jsort_2',		$jsort_2);
		
		
		
		
        parent::display($tpl);
    }
	
	
}
?>